#!/usr/bin/make -f

SHELL=/bin/bash
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
#JPEGLIBDIR=$(LIBDIR)/libgpujpeg

%:
	dh $@

override_dh_auto_configure:
	./autogen.sh || true
	dh_auto_configure -- --disable-static --enable-opengl --libdir=$(LIBDIR) # LDFLAGS="$(LDFLAGS) -Wl,-rpath=$(JPEGLIBDIR)"

#override_dh_auto_install:
#	dh_auto_install
#	mkdir -p debian/tmp/$(JPEGLIBDIR)
#	sh -c "$$(ldd bin/gpujpeg $$(find . -name '*.so*') 2>/dev/null | grep cuda | grep -E '^[[:space:]]+' | sed -r 's#[[:space:]]+([^[:space:]]+)[[:space:]]+=>[[:space:]]+([^[:space:]].*)[[:space:]]+[(][^)]+[)]#cp "$$(realpath "\2")" debian/tmp$(JPEGLIBDIR)/\1#g' | uniq | tr $$'\n' ';')"

override_dh_shlibdeps:
	dh_shlibdeps -- --ignore-missing-info

